package cn.minsh.lims.eoms.modules.app.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.awt.*;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.minsh.lims.eoms.common.utils.PageUtils;
import cn.minsh.lims.eoms.common.utils.Query;

import cn.minsh.lims.eoms.modules.app.dao.PlanRemindDao;
import cn.minsh.lims.eoms.modules.app.entity.PlanRemindEntity;
import cn.minsh.lims.eoms.modules.app.service.PlanRemindService;


@Service("planRemindService")
public class PlanRemindServiceImpl extends ServiceImpl<PlanRemindDao, PlanRemindEntity> implements PlanRemindService {

    @Autowired
    private PlanRemindDao planRemindDao ;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PlanRemindEntity> page = this.page(
                new Query<PlanRemindEntity>().getPage(params),
                new QueryWrapper<PlanRemindEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void deleteByPlanId(Integer type, Long planId) {
        QueryWrapper<PlanRemindEntity> wrapper = new QueryWrapper<>() ;
        wrapper.eq("type",type) ;
        wrapper.eq("plan_id",planId) ;
        planRemindDao.delete(wrapper) ;
    }

    @Override
    public List<PlanRemindEntity> listByTypeAndPlanId(Integer type, Long planId) {
        QueryWrapper<PlanRemindEntity> wrapper = new QueryWrapper<>() ;
        wrapper.eq("type",type) ;
        wrapper.eq("plan_id",planId) ;
        return planRemindDao.selectList(wrapper);
    }
}